<table class="table table-striped goods_list_table   table-bordered">
    <thead>
        <tr>
                   <th class="opth50"><label>
          <input type="checkbox"  id="allsel" value="" > <span class="lbl"></span>
          </label></th>  
        	<th class="opth100">采购标题</th>
            <th class="opth100">到期时间</th>
            <th class="opth70">备注说明</th>
            <th class="opth70">操作人员</th>
            <th class="opth70">采购状态</th>
            <th class="opth70">操作时间</th>
            <th class="opth70">操作</th>
        </tr>
    </thead>
    <tbody id="tbodylist">
        <volist name="_datalist['lists']" id="g">
            <tr>
                 <td><input
                      type="checkbox" class="ace"  value="{$g.purchaseid}" > <span class="lbl"></span>
                  </td> 
                <td>{$g['purchaseame']}</td>
            	<td>{$g['lasttime']}</td>
            	<td>{$g['remark']}</td>
                <td>{$g['user_name']}</td>
                <td>
                 <if condition="$g.isactive eq 0 ">
                        无效
                <elseif condition="$g.isactive eq 1 "/>
                        有效
                <else/>
                        <span style="color:red;">完成</span>
                </if>
                </td>
                <td>{$g['createtime']}</td>
                <td>
                


                <if condition="$g.isactive eq 0 ">
                <a class="btn btn-default btn-primary" href="javascript:;" onclick="check_isactive(this,0)" url="{:U('update_wx_purchase',array('purchaseid'=>$g['purchaseid']))}"  purchaseid="{$g.purchaseid}" >编辑</a>
                <a class="btn btn-default btn-primary" url="{:U('add_wx_purchaselist',array('purchaseid'=>$g['purchaseid']))} "  purchaseid="{$g.purchaseid}" onclick="check_isactive(this,1)" >添加采购商品</a>
               <a class="btn btn-default btn-primary" href="delete_wx_purchase?id={$g['purchaseid']}" onclick="Javascript:return confirm('确定要删除吗？');">删除</a>
                <a  class="btn btn-default btn-primary" onclick="return confirm('确定将此记录设置有效?')" href="{:U('set_purchase_isactive',array('purchaseid'=>$g['purchaseid'],'isactive'=>1))}">开启采购</a>


                <elseif condition="$g.isactive eq 1 "/>


                <!--  <a  class="btn btn-default btn-primary" onclick="return confirm('确定将此记录设置无效?')" href="{:U('set_purchase_isactive',array('purchaseid'=>$g['purchaseid'],'isactive'=>0))}">设置无效</a> -->
                <span class="btn btn-white" >采购进行中</span>

                <a class="btn btn-default btn-primary" href="javascript:;"onclick="_es_openDilogLargeid('{:U('offer_details',array(purchaseid=>$g['purchaseid']))}','采购单详情')" >查看采购单详情</a>
                 <else/>
                    <span class="btn btn-success" >采购结束</span>
<!-- <a class="btn btn-default btn-primary" href="delete_wx_purchase?id={$g['purchaseid']}" onclick="Javascript:return confirm('确定要删除吗？');">删除</a> -->
                <a class="btn btn-default btn-primary" href="javascript:;"onclick="_es_openDilogLargeid('{:U('offer_details',array(purchaseid=>$g['purchaseid']))}','采购单详情')" >查看采购单详情</a>

                </if>


                </td>
            </tr>
        </volist>
    </tbody>
</table>
   <button class='btn btn-danger' onclick="all_delete_wx_vest()">批量删除</button>
<notempty name="_datalist['lists']">
  <div class="page_list_ops dataTables_paginate paging_bootstrap pagination">
    {$_datalist['page_html']}
 </div> 

</notempty>
<script type="text/javascript">

  

   $(function(){
           $("#allsel").bind("click",checkSel);
    })
function check_isactive(_this,type){
    var purchaseid = $(_this).attr('purchaseid');
    var url=$(_this).attr('url');
   $.ajax({
             'url': "{:U('purchase_is_isactive')}",
             'data': {'purchaseid':purchaseid},
             'dataType': 'json',
             'type': 'POST',
             success: function (data) {
                 if (data.staute =="success") {  
                    if(type==0){
                       _es_openDilogLarge(url,'编辑采购单'); 
                    }
                   
                   if(type==1){
                    location.href = url;
                   }
                 }else{
                   alert(data.msg); 
                 }


             }, error: function (err) { 

                 art.dialog({title:'温馨提示',content: err.responseText, ok: function () {this.close();return false;},okval:'确定'});
             },complete: function () {
                
             }
         });

}



 function checkSel(){
   var flg= $(this).is(":checked");
   $("input[type='checkbox']").prop("checked",flg);
}
 //批量删除有效无效
function all_delete_wx_vest(){
     //获取需要删除信息
     var _val=selallval();
     if(_val==""){
         alert("请勾选需要删除的记录!");
         return false;
     }
     $.ajax({
             'url': "{:U('all_delete_wx_purchase')}",
             'data': {'allid':_val},
             'dataType': 'json',
             'type': 'POST',
             success: function (data) {
                 if (data.staute =="success") {  
                    alert(data.msg);
                      _load_html_byurl("{:U('purchaseList')}", "load_tb_div");
                 }

             }, error: function (err) { 

                 art.dialog({title:'温馨提示',content: err.responseText, ok: function () {this.close();return false;},okval:'确定'});
             },complete: function () {
                
             }
         });

}  

var selallval=function(){
     var _list="";
     $("input[type='checkbox']:checked").each(function(){
         // var flg=$(this).is(":checked");
         //if(!flg)return false;
         var _val=$(this).val();
         if(_val!=""){
         _list+= (_list==""?"":",")+"'"+_val+"'";
         } 
     });
     return _list;
}  
</script>